// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Test.generated.h"

class AAnsyActor;
/**
 * 
 */
class RUNABLETEST_API FCountRunnable : public FRunnable
{
public:
	FCountRunnable(AAnsyActor* InOwner);
	~FCountRunnable();

	virtual bool Init() override;
	virtual uint32 Run() override;
	virtual void Stop() override;
	virtual void Exit() override;

private:
	AAnsyActor* Owner;
	std::atomic<bool> bStop;

	TQueue<int32> CurrentCountQue;
};

UCLASS()
class RUNABLETEST_API AAnsyActor : public AActor
{
	GENERATED_BODY()
public:
	AAnsyActor();
	virtual ~AAnsyActor() override;

	void StartFRunnableCount();
	void StopFRunnableCount();

	int32 GetCurrentCount() const;

	void SetCurrentCount(int32 NewCount);

protected:
	virtual void BeginPlay() override;
	virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;

private:
	std::atomic<int32> CurrentCount;
	FCountRunnable* CountRunnable;
	FRunnableThread* CountThread;
	
	
};
